<template>
  <view class="pdfPreview">
    <web-view :src="webView.src"></web-view>
  </view>
</template>
<script>
let eventChannel
import { mapGetters, mapMutations } from 'vuex'

export default {
  components: {},
  computed: {
    ...mapGetters(['userInfo', 'api'])
  },
  props: {},
  data() {
    return {
      webView: {
        src: '',
        //要请求的api
        api: {},
        type: '',
        token: '',
        applicationId: '',
        sealInfoId: '',
        enterpriseContractId: '',
        baseUrl: uni.getStorageSync('baseUrl')
      }
    }
  },
  onLoad(op) {
    uni.setNavigationBarTitle({title: this.$t('PDF预览')})
    eventChannel = this.getOpenerEventChannel()
    eventChannel.on('pagePramas', (data) => {
      //console.log(data);
      this.processingData(data)
    })
  },
  onShow() {},
  methods: {
    processingData(data) {
      this.webView.token = this.userInfo.token
      this.webView.type = data.type
      if (data.type == '申请单记录') {
        this.webView.applicationId = data.applicationId
      } else if (data.type == '盖章记录') {
        this.webView.sealInfoId = data.sealInfoId
        this.webView.sealId = data.sealId
      } else if (data.type == '合同管理') {
        this.webView.enterpriseContractId = data.enterpriseContractId
      }
      this.webView.api = {
        GLOBAL_application_getAuditorApplicationById:
          this.api.GLOBAL_application_getAuditorApplicationById, //详情
        GLOBAL_electronic_seal_info_findContractDetail:
          this.api.GLOBAL_electronic_seal_info_findContractDetail, //详情
        GLOBAL_app_electronic_enterprise_contract_findEnterpriseContractInfo:
          this.api.GLOBAL_app_electronic_enterprise_contract_findEnterpriseContractInfo //详情
      }
      this.webView.src =
        '/hybrid/html/pages/pdfPreview.html?data=' +
        encodeURIComponent(JSON.stringify(this.webView))
    }
  }
}
</script>

<style lang="scss">
.pdfPreview {
}
</style>
